/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * Description: Hmfs-tools resize load sit
 */

#ifndef LOAD_SIT_H
#define LOAD_SIT_H

#include <iostream>

#include "hmfs_fs.h"
#include "hmfs_log.h"
#include "resize_data.h"
#include "resize_utils.h"

namespace OHOS {
namespace Hmfs {
class ResizeLoad;
class LoadSit {
public:
    LoadSit(ResizeLoad *loadPtr);
    ~LoadSit() = default;
    bool IsSyncDataRecord();
    int32_t BuildSitInfo();
    uint32_t GetStartSumBlock();
    uint32_t GetSummaryBlockAddr(int32_t base, int32_t type);
    void ReadCompactSummaries();
    void RestoreNodeSummary(uint32_t sitNumber, SummaryBlockData *summaryBlock);
    void ReadNormalSummaries(int32_t type);
    void UpdateCurSegSummaries();
    int32_t BuildCurSegment();
    int32_t BuildSegmentBegin();
    int32_t BuildSitEntries();
    void InsideSegInfoFromRawSit(SegmentEntry *sitEntry, SitEntry *rawSit);
    void SegInfoFromRawSit(SegmentEntry *sitEntry, SitEntry *rawSit);
    void CheckBlockCount(uint32_t sitNumber, SitEntry *rawSit);
    int32_t LateBuildSegmentManager();

private:
    int32_t InitializeSitInfo(SitInfo *sitInfo, uint32_t mainSegments);
    ResizeLoad *load_ = nullptr;
    std::shared_ptr<HmfsConfigData> config_ = nullptr;
    std::shared_ptr<HmfsSuperBlockInfo> superBlockInfo_ = nullptr;
};
} // namespace Hmfs
} // namespace OHOS
#endif // LOAD_SIT_H
